<?php
class Member_detail extends CI_Controller {
	public function __construct() {
		parent::__construct ();
		// 登录校验
		$this->common->check_login_admin ();
		$this->load->helper ( array (
				'form',
				'url' 
		) );
	}
	
	/**
	 * 修改会员信息
	 */
	public function index() {
		$this->load->model ( 'user_model' );
		
		$result = $this->user_model->get_user_info_id ( $_GET ['id'] );
		$data ['user'] = $result;
		
		$data ['left'] = $this->load->view ( 'admin/left', '', TRUE );
		$data ['menu'] = $this->load->view ( 'admin/menu', '', TRUE );
		$this->load->view ( 'admin/member_detail', $data, FALSE );
	}
	
	/**
	 * 修改会员信息
	 */
	public function member_update() {
		if ($_POST ['pwd'] !== $_POST ['pwd2'] || $_POST ['spwd'] !== $_POST ['spwd2']) {
			exit ( $this->common->alert_msg_goback ( '注册失败，二次密码不符。' ) );
		}
		
		//if (empty ( $_POST ['user_account'] ) || empty ( $_POST ['pwd'] ) || empty ( $_POST ['spwd'] ) || empty ( $_POST ['user_name'] ) || empty ( $_POST ['zfb_account'] )) {
		//	exit ( $this->common->alert_msg_goback ( '注册失败，内容不全。' ) );
		//}
		
		$this->load->model ( 'user_model' );
		$result = $this->user_model->update_userinfo_gyb ( $_REQUEST ['id'] );
		
		if ($result) {
			exit ( $this->common->alert_msg_url ( '修改成功', site_url ( 'admin/my_member' ) ) );
		} else {
			exit ( $this->common->alert_msg_goback ( '修改失败' ) );
		}
	}
}